﻿using System.Windows;
using MC.Warehouse.Core;

namespace MC.Warehouse.ViewModels
{
	public class LoginViewModel : WindowViewModel
	{
        //private AccoutModel _account;

	    #region Properties
        public string Username { get; set; }
        //{
        //    get
        //    {
        //        return _account.Username;
        //    }
        //    set
        //    {
        //        _account.Username = value;
        //        NotifyPropertyChanged("Username");
        //    }
        //}

        public string Password { get; set; }
        //{
        //    get
        //    {
        //        return _account.Password;
        //    }
        //    set
        //    {
        //        _account.Password = value;
        //        NotifyPropertyChanged("Password");
        //    }
        //}
        #endregion

        

        private RelayCommand _cmdLogin;
        public RelayCommand CmdLogin
        {
            get { return _cmdLogin ?? (_cmdLogin = new RelayCommand(param => Logon())); }
        }

        private RelayCommand _cmdCancel;
        public RelayCommand CmdCancel
        {
            get { return _cmdCancel ?? (_cmdCancel = new RelayCommand(param => Exit())); }
        }

        private void Exit()
        {
            Application.Current.Shutdown();
        }

        private void Logon()
        {
            Application.Current.MainWindow = new MainWindow();
            var window = Application.Current.Windows[0];
            if (window != null) window.Close();
            Application.Current.MainWindow.Show();
        }
	}
}